<?php

class BookController extends Controller
{
	public function info()
	{
		$bookid	=	Lib::get('id', 'int');
		$book	=	Book::getBook($bookid);
		if(!$book)
		{
			Show::go400("no such book");
		}
		$this->assign('book', $book);
		$this->display();
	}
	
	public function reader()
	{
		$bookid	=	Lib::get('id', 'int');
		$book	=	Book::getBook($bookid);
		if(!$book)
		{
			Show::go400("no such book");
		}
		$this->assign('book', $book);
		
		try {
			$cont	=	ReaderHelper::getChapter($book['path']);
		}catch(Exception $e){
			Show::go400($e->getMessage());
		}
		$this->assign('content',	ReaderHelper::htmlFormat($cont));
		$this->assign('page',		ReaderHelper::getPager($book['length'], $cont));
		
		$this->display();
	}
	
	
}

?>